<?php
/**
 * Created by PhpStorm.
 * User: 17208
 * Date: 2020/9/28
 * Time: 18:02
 */

namespace app\utility;


use extend\Config;
use EasyWeChat\Factory;

class WeChatApp
{
    private static $instance = null;
    public static function get(){
        if(!self::$instance){
            self::$instance = self::create();
        }
        return self::$instance;
    }
    protected static function create(){
        $config = Config::get('wechat');
        $config = [
            'app_id' => $config['app_id'],
            'secret' => $config['secret'],
            'token' => $config['token'],
            'aes_key' => $config['aes_key'],
            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',
        ];
        return Factory::officialAccount($config);
    }
}